
function trim(str) {
    return str.replace(/^\s+|\s+$/g, '');
}
let str = "   hello   "
str = str.trim();
console.log(str.length);